package com.cictec.cloud.app.appserver.ribbon.impl;

import com.cictec.cloud.app.appserver.ribbon.IConsumerService;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

/**
 * @author :zoboy
 * @Description:
 * @ Date: Created in 2020-05-09 17:35
 */
@Service
public class ConsumerServiceImpl implements IConsumerService {

    @Autowired
    RestTemplate restTemplate;

    @HystrixCommand(fallbackMethod = "fallback")
    @Override
    public String consumer() {
        return restTemplate.getForObject("http://order-service/dc", String.class);
    }

    public String fallback() {
        return "fallback";
    }
}
